#include <bits/stdc++.h>

using namespace std;

struct node{
    int data;
    node *next;
};

int main(){
    int n, m;
    cin >> n >> m;

    node *head, *p , *now, *prev;
    head = new node;
    head->data = 1;
    head->next = nullptr;

    now = head;
    for (int i = 2; i <= n; i++){
        p = new node;
        now->next = p;
        p->next = nullptr;
        p->data = i;
        now = p;
    }
    now->next = head;
    
    prev = now;
    now = head;
    while ((n--) > 1){
        for (int i = 1; i < m; i++){
            prev = now;
            now = prev->next;
        }
        cout << now->data << " ";
        prev->next = now->next;
        delete now;
        now = prev ->next;
    }
    cout << now->data;
    delete now;

    return 0;
}